package com.skplanet.oneplusonewindow.moimserver.domain;

import java.io.Serializable;
import java.text.DateFormat;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Type;

import com.fasterxml.jackson.annotation.JsonIgnore;

@Entity
@Table(name = "MOIM_PLAZACOMMENT")
public class Moim_PlazaComment implements Serializable{

	public Long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	public Moim_PlazaBoard getPlazaboard() {
		return plazaboard;
	}

	public void setPlazaboard(Moim_PlazaBoard plazaboard) {
		this.plazaboard = plazaboard;
	}

	private static final long serialVersionUID = -909322011332867664L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;
	
	@Column(name = "userId")
	private Long userId;
	
	@Column(name = "content")
	@Type(type="text")
	private String content;
	
	@Column(name = "regdate")
	private String regdate;
	
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "plazaboard_id")
	@JsonIgnore
	private Moim_PlazaBoard plazaboard;
	
	public Moim_PlazaComment(){
		Date date = new Date();
		DateFormat format1 = DateFormat.getDateInstance(DateFormat.MEDIUM);
		setRegdate(format1.format(date));
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getContent() {
		return content.replaceAll("\n", "<br/>");
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getRegdate() {
		return regdate;
	}

	public void setRegdate(String regdate) {
		this.regdate = regdate;
	}
	
}
